package June;

public class Account {
    private String name;
    private double balance;
    private String passwrod;

    public Account() {
    }

    public Account(String name, double balance, String passwrod) {
        this.name = name;
        this.balance = balance;
        this.passwrod = passwrod;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        //设置名字长度为2~6
        if (name.length() >= 2 && name.length() <= 6) {
            this.name = name;
        } else {
            System.out.println("名字设置有误，长度需为2~6，默认为“无名”");
            this.name = "无名";
        }
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        //设置余额最小为20
        if (balance >= 20) {
            this.balance = balance;
        } else {
            System.out.println("余额设置有误，需为 大于20， 默认为 0");
            this.balance = 20;
        }
    }

    public String getPasswrod() {
        return passwrod;
    }

    public void setPasswrod(String passwrod) {
        //密码长度为6位数
        if (passwrod.length() == 6) {
            this.passwrod = passwrod;
        } else {
            System.out.println("密码设置有误，密码长度为6位数， 默认为 000000");
            this.passwrod = "000000";
        }
    }
    public void info() {
        System.out.println(name + "  " + balance + "  " + passwrod);
    }
}
